package com.changgou.goods.dao;

import com.changgou.goods.pojo.Brand;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

public interface BrandMapper extends Mapper<Brand> {

    /**
     * @Description: TODO(根据分类名称查询品牌列表)
     */
    @Select("SELECT tb_brand.name,tb_brand.image " +
            "FROM tb_brand LEFT JOIN  tb_category_brand" +
            " ON tb_brand.id = tb_category_brand.brand_id LEFT JOIN " +
            "tb_category ON tb_category.id = tb_category_brand.category_id " +
            "WHERE tb_category.name = #{categoryName}")
    public List<Map> findListByCategoryName(@Param("categoryName") String categoryName);

    /**
     * @Description: TODO(根据分类名称查询规格列表)
     */
    @Select("SELECT name,options FROM tb_spec WHERE template_id" +
            " in (SELECT template_id FROM tb_category WHERE name = #{categoryName})")
    public List<Map> findSpecByCategoryName(@Param("categoryName") String categoryName);

}
